package com.lc.ck.common;

import lombok.Data;

import java.util.List;

@Data
public class Result {
    private int code;//200/400
    private String msg;//成功/失败
    private Long total;//总记录数
    private Object data;//数据

    public static Result fail(){//失败
        return result(400,"失败",0L,null);
    }
    public static Result suc(){//成功，无数据
        return result(200,"成功",0L,null);
    }
    public static Result suc(Object data){//成功，有数据
        return result(200,"成功",0L,data);
    }
    public static Result suc(Object data, Long total){//成功，列表
        return result(200,"成功",total,data);
    }
    private static Result result(int code, String msg,Long total, Object data){
        Result res = new Result();
        res.setCode(code);
        res.setData(data);
        res.setMsg(msg);
        res.setTotal(total);
        return res;
    }
}
